package lex.profile.ui.outline;

import lex.profile.utils.StringUtils;
import lex.swing.outline.AbstractRowModel;

import com.vladium.utils.IObjectProfileNode;

public class ProfileRowModel extends AbstractRowModel
{
	private static final String[] COLUMN_NAMES = { "Class", "Value", "Size", "References" };

	@Override
	public int getColumnCount()
	{
		return COLUMN_NAMES.length;
	}

	@Override
	public Object getValueFor( Object node, int column )
	{
		IObjectProfileNode pn = (IObjectProfileNode) node;
		switch( column )
		{
		case 0:
			// name
			if( null == pn.object() )
				return "(unkown)";
			else
				return StringUtils.toString( pn.object().getClass() );
		case 1:
			//value
			return pn.object();
		case 2:
			//size
			return pn.size();
		case 3:
			//ref
			return pn.refcount();
		default:
			return "";
		}
	}

	@Override
	public Class<?> getColumnClass( int column )
	{
		switch( column )
		{
		case 0:
			return String.class;
		case 1:
			return Object.class;
		case 2:
			return Integer.class;
		case 3:
			return Integer.class;
		default:
			return Object.class;
		}
	}

	@Override
	public String getColumnName( int column )
	{
		return COLUMN_NAMES[column];
	}
}
